﻿using System.Data.SqlClient;

namespace EntityMap.AdoNETTest
{
    internal class Program
    {
        static void Main(string[] args)
        {
            try
            {
                //ADO.NET--引入程序集--Nuget
                string connectionString = "Data Source=WIN-20231020MLM;Initial Catalog=AdvancedCustomerDB;Integrated Security=True;TrustServerCertificate=True";
                using (SqlConnection connection = new SqlConnection(connectionString))
                {
                    Console.WriteLine($"状态：{connection.State}");
                    connection.Open(); //打开链接
                    Console.WriteLine($"状态：{connection.State}");
                    connection.Close();
                    Console.WriteLine($"状态：{connection.State}");
                    //数据库的命令对象--专门用来执行命令 
                }



                Console.ReadKey();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }   
        }
    }
}
